import pymysql
from config.readConfig_59 import ReadConfig_59

mysql = ReadConfig_59()

class MysqlDb_59:
    def __init__(self):
        self.host = mysql.Database("host")
        self.user = mysql.Database("user")
        self.passwd = mysql.Database("passwd")
        self.port = mysql.Database("port")
        self.database = mysql.Database("database")
        self.db = pymysql.connect(self.host,self.user,self.passwd,self.database)

    def execute(self,sql,data):
        connect = self.db
        cursor = connect.cursor()
        cursor.execute(sql % data)
        connect.commit()

    def execute_read(self,sql,data):
        connect = self.db
        cursor = connect.cursor()
        cursor.execute(sql % data)
        for row in cursor.fetchall():
            return row

    def realname_status(self):
        sql = mysql.Mysql("realname_status")
        #sql = SELECT realname_status FROM user_main WHERE user_name = 'Wj121212'
        data = self.execute_read(sql,())
        return data